package com.bootdo.app;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bootdo.change.entity.SpecialVo;
import org.apache.poi.hmef.attribute.MAPIAttribute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import com.bootdo.app.service.CreateTaskService;
import com.bootdo.change.entity.ChangeTask;
import com.bootdo.change.entity.ChangeTaskVo;
import com.bootdo.change.service.ChangeTaskService;
import com.bootdo.common.utils.AppR;
import com.bootdo.goods.domain.TGoodsAllocationAloneDO;
import com.bootdo.goods.domain.TGoodsAllocationDO;
import com.bootdo.goods.service.TGoodsAllocationAloneService;
import com.bootdo.goods.service.TGoodsAllocationService;
import com.bootdo.provider.domain.GoodsInfoDO;
import com.bootdo.provider.domain.ProviderInfoDO;
import com.bootdo.provider.service.GoodsInfoService;
import com.bootdo.provider.service.ProviderInfoService;
import com.bootdo.staff.domain.StaffUserDO;
import com.bootdo.staff.service.StaffUserService;
import com.bootdo.task.domain.TTaskDO;
import com.bootdo.task.domain.TTaskDatilDO;
import com.bootdo.task.service.TTaskDatilService;
import com.bootdo.task.service.TTaskService;

/***
 * 调仓接口类
 * @author wlst
 *
 */
@Controller
@CrossOrigin
@RequestMapping("api/change")
public class AppChangeController {
	@Autowired
	private CreateTaskService createTaskService;
	
	@Autowired
	private TGoodsAllocationService goodsAllocationService;
	@Autowired
	private ChangeTaskService changeTaskService;
	
	@Autowired
	private StaffUserService staffUserService;

	@Autowired
	private TTaskService tTaskService;
	
	@Autowired
	private TTaskDatilService tTaskDatilService;
	
	@Autowired
	private GoodsInfoService goodsInfoService;
	
	@Autowired
	private ProviderInfoService providerInfoService;

	@Autowired
	private TGoodsAllocationAloneService tGoodsAllocationAloneService;
	/***
	 * 正常调仓根据货位编号查询对应商品信息
	 * @param allocationNumber 货位编号
	 * @return
	 */
	@ResponseBody
	@GetMapping("/selectMsg")
	public AppR select(@RequestParam String allocationNumber){
		TGoodsAllocationDO tGoodsAllocationDO = goodsAllocationService.getOne(allocationNumber);
		if (tGoodsAllocationDO == null){
			return AppR.error(900,"输入信息有误或该仓位是空仓位");
		}else {
			if (!(tGoodsAllocationDO.getAllocationType().equals("122001") || tGoodsAllocationDO.getAllocationType().equals("122002"))){
				return AppR.error(900,"仓位是特殊仓位");
			}else{

				if (tGoodsAllocationDO.getGoodsId()==null) {
					return AppR.error(900,"仓位暂无商品信息");
				}else{

					GoodsInfoDO goodsInfoDO = goodsInfoService.get(tGoodsAllocationDO.getGoodsId());//商品信息
					ProviderInfoDO providerInfoDO = providerInfoService.get(tGoodsAllocationDO.getProviderId());//供应商信息

					Map<String,Object> map = new HashMap<>();
					if (tGoodsAllocationDO.getAllocationId()!=null) {
						map.put("allocationId", tGoodsAllocationDO.getAllocationId());//货位ID
					}else{
						map.put("allocationId", " ");//货位ID
					}
					if (goodsInfoDO.getGoodsName()!=null) {
						map.put("goodsName", goodsInfoDO.getGoodsName());//商品名称
					}else {
						map.put("goodsName", " ");//商品名称
					}
					if (goodsInfoDO.getGoodsStandard()!=null) {
						map.put("goodsStandard", goodsInfoDO.getGoodsStandard());//规格
					}else{
						map.put("goodsStandard", " ");//规格
					}
					if (tGoodsAllocationDO.getGoodsNumber()!=null) {
						map.put("goodsNumber", tGoodsAllocationDO.getGoodsNumber());//仓位货物数量
					}else {
						map.put("goodsNumber", " ");//仓位货物数量
					}
					if (goodsInfoDO.getGoodsPackagingType()!=null){
						map.put("goodsPackagingType", goodsInfoDO.getGoodsPackagingType());//商品单位
					}else {
						map.put("goodsPackagingType", " ");//商品单位
					}
					if (goodsInfoDO.getGoodsCases()!=null) {
						map.put("goodsCases", goodsInfoDO.getGoodsCases());//箱零比
					}else {
						map.put("goodsCases", " ");//箱零比
					}
					if (providerInfoDO.getProviderFname()!=null) {
						map.put("providerFname", providerInfoDO.getProviderFname());//供应商全称
					}else {
						map.put("providerFname", " ");//供应商全称
					}

					return AppR.ok(map);
				}
			}
		}

	}
	
	/***
	 * 手动常规调仓提交
	 * @param allocationNumberS 初始货位标号
	 * @param allocationNumberE 目标货位标号
	 * @param userid 登陆者ID
	 * @param roleid 分配到到员工ID
	 * @param context 备注
	 * @return
	 */
	@ResponseBody
	@PostMapping("/changeMsg")
	public AppR changeSeat(@RequestParam String allocationNumberS,@RequestParam String allocationNumberE,@RequestParam Long userid,@RequestParam Long roleid,String context){

		if (allocationNumberS != null && allocationNumberE != null) {//判断两个参数是否为空
			
			TGoodsAllocationDO list1 = goodsAllocationService.getOne(allocationNumberS);
			TGoodsAllocationDO list2 = goodsAllocationService.getOne(allocationNumberE);
			if (!(list1.getAllocationType().equals("122001") || list2.getAllocationType().equals("122002"))) {
				return AppR.error(900,"特殊仓位不能调仓");
			}else{
				if (!(list1.getAllocationStatus().equals("120004") || list2.getAllocationStatus().equals("120004"))) {
					if (list1.getGoodsId() == null) {
						return AppR.error(900,"初始仓位不能是空或输入信息有误");
					}else{
						if (list2.getGoodsId() == null ) {//有到无
							if (list1.getProviderId()!=list2.getProviderId()) {
								return AppR.error(900,"非同一供应商不能合仓");
							}else{
								//有到无  挂到调仓任务表
								Long providerId = list1.getProviderId();
								Long goodsId = list1.getGoodsId();
								Integer goodsNumber = list1.getGoodsNumber();
								Long sid = list1.getAllocationId();
								Long eid = list2.getAllocationId();
								
								toChange(sid,eid,userid,roleid,providerId,goodsId,allocationNumberS,allocationNumberE,context,goodsNumber);
							}
							
						}else{
							if (list1.getGoodsId() != list2.getGoodsId() ) {
								return AppR.error(900,"非同一种商品不能合仓");
							}else{
								if (list1.getProviderId() != list2.getProviderId()) {
									return AppR.error(900,"非同一供应商不能合仓");
								}else{
									//有到有    挂到调仓任务列表
									Long providerId = list1.getProviderId();
									Long goodsId = list1.getGoodsId();
									Integer goodsNumber = list1.getGoodsNumber();
									Long sid = list1.getAllocationId();
									Long eid = list2.getAllocationId();
									toChange(sid,eid,userid,roleid,providerId,goodsId,allocationNumberS,allocationNumberE,context,goodsNumber);
								}
								
							}

						
						}
						
					}
				}else{
					return AppR.error(900,"仓位被锁定，无法调仓");
				}
			}
			
			
		}else{
			return AppR.error("系统异常，重新操作");
		}
		return AppR.ok("调仓任务发布成功");
	
	}
	
	
	/***
	 * 被调用的调仓方法
	 */
	public AppR toChange(Long sid,Long eid,Long userid,Long roleid,Long providerId,Long goodsId,String allocationNumberS,String allocationNumberE,String context,Integer goodsNumber){
		
		
		StaffUserDO staffUserDO = staffUserService.get(userid);
		StaffUserDO staffUser = staffUserService.get(roleid);
		if (staffUserDO!=null && staffUser != null) {
			String str = UUID.randomUUID().toString();
			
			ChangeTask ct = new ChangeTask();
			
			ct.setId(str);
			ct.setTdStime(new Date());
			ct.setTdInitalAllocation(sid);
			ct.setTdTargetAllocation(eid);
			ct.setTdName(staffUserDO.getStaffName());
			ct.setTdDoname(staffUser.getStaffName());
			ct.setRoleId(roleid);
			ct.setTdStatus(0);
			ct.setTdType(1);
			ct.setProviderId(providerId);
			ct.setGoodsId(goodsId);
			ct.setChangeNumber(goodsNumber);
			ct.setAllocationNumberS(allocationNumberS);
			ct.setAllocationNumberE(allocationNumberE);
			if (context!=null) {
				ct.setContext(context);
			}
			changeTaskService.save(ct);
			//锁定初始仓位和目标仓位
			goodsAllocationService.updateOne("120004",sid);
			goodsAllocationService.updateOne("120004",eid);
		}else{
			return AppR.error(900,"系统异常，用户信息错误！");
		}
		
		return AppR.ok("完成");
	}

	/***
	 * 发布调仓任务时获取叉车工人列表
	 */
	@ResponseBody
	@GetMapping("/selectchgMsg")
	public AppR listC(){
		List<StaffUserDO> selectAll = staffUserService.selectAll();
		Map<String,Object> h= new HashMap<>();
		h.put("list", selectAll);
		return AppR.ok(h);
		
	}
	
	/***
	 * 任务列表页
	 * roleId 登陆者ID
	 */
	@ResponseBody
	@GetMapping("/selectTaskMsg")
	public AppR list(@RequestParam Long roleId){
		//if (id == null) {
			//判断有无任务
			ChangeTask have = changeTaskService.haveTask(roleId);
			if (have!=null) {
				Map<String,Object> map = new HashMap<>();
				//判断上一个调仓任务是否有订单号
				ChangeTask selectOver = changeTaskService.selectOver(roleId);
				if (selectOver!=null) {
					if (selectOver.getOrderId() == null) {//上条任务不存在订单号
						//根据登陆ID，查处时间最早未完成的一条j加急记录
						ChangeTask all = changeTaskService.getOne(roleId);
						if (all==null) {//没有待完成待加急任务
							ChangeTask changeTask = changeTaskService.getNew(roleId);//分配一条未完成和时间最早待记录
							//Map<String,Object> map = new HashMap<>();
							ChangeTaskVo changeTaskVo = new ChangeTaskVo();
							aaa(changeTask,changeTaskVo);
							return AppR.ok(changeTaskVo);
						}else{


							//Map<String,Object> map = new HashMap<>();
							ChangeTaskVo changeTaskVo = new ChangeTaskVo();
							aaa(all,changeTaskVo);
							return AppR.ok(changeTaskVo);
						}
						
					}else{
						//上条任务存在订单号，查同一订单时间最早的未完成的一条记录
						ChangeTask sall = changeTaskService.selectAll(roleId,selectOver.getOrderId());
						if (sall == null) {
							ChangeTask all = changeTaskService.getOne(roleId);
							if (all==null) {
								ChangeTask changeTask = changeTaskService.getNew(roleId);
								
								//Map<String,Object> map = new HashMap<>();
								ChangeTaskVo changeTaskVo = new ChangeTaskVo();
								aaa(changeTask,changeTaskVo);
								return AppR.ok(changeTaskVo);
								
							}else{
								
								//Map<String,Object> map = new HashMap<>();
								ChangeTaskVo changeTaskVo = new ChangeTaskVo();
								aaa(all,changeTaskVo);
								return AppR.ok(changeTaskVo);
							}
						}else{
							//Map<String,Object> map = new HashMap<>();
							ChangeTaskVo changeTaskVo = new ChangeTaskVo();
							aaa(sall,changeTaskVo);
							return AppR.ok(changeTaskVo);
						}
						
					}
				}else{
					//根据登陆ID，查处时间最早未完成的一条加急记录
					ChangeTask all = changeTaskService.getOne(roleId);
					if (all==null) {//没有待完成待加急任务
						ChangeTask changeTask = changeTaskService.getNew(roleId);//分配一条未完成和时间最早待记录
						//Map<String,Object> map = new HashMap<>();
						ChangeTaskVo changeTaskVo = new ChangeTaskVo();
						aaa(changeTask,changeTaskVo);
						return AppR.ok(changeTaskVo);
					}else{
						//Map<String,Object> map = new HashMap<>();
						ChangeTaskVo changeTaskVo = new ChangeTaskVo();
						
						aaa(all,changeTaskVo);
						
						return AppR.ok(changeTaskVo);
					}
				}
				
			}else{
				return AppR.ok("暂无任务");
			}
	//	}else{
	//		ChangeTask have = changeTaskService.get(id);
	//		return AppR.ok(have);
	//	}	
			
	
	}
	
	
	public ChangeTaskVo aaa(ChangeTask changeTask,ChangeTaskVo changeTaskVo){
		GoodsInfoDO goodsInfoDO = goodsInfoService.get(changeTask.getGoodsId());//商品信息
		TGoodsAllocationDO tGoodsAllocationDO = goodsAllocationService.get(changeTask.getTdInitalAllocation());
		TGoodsAllocationDO tGoodsAllocationDO2 = goodsAllocationService.get(changeTask.getTdTargetAllocation());		
		if (changeTask.getTdStatus()!=null){
			changeTaskVo.setTdStatus(changeTask.getTdStatus());
		}else{
			changeTaskVo.setTdStatus(3);//3相当于String类型的空串，无实际意义
		}
		if (changeTask.getAllocationNumberS()!=null) {
			changeTaskVo.setAllocationNumberS(changeTask.getAllocationNumberS());//初始仓位编号
		}else{
			changeTaskVo.setAllocationNumberS("");//初始仓位编号
		}
		if (changeTask.getId()!=null) {
			changeTaskVo.setIdS(changeTask.getId());
		}else{
			changeTaskVo.setIdS("");
			
		}
		if (goodsInfoDO.getGoodsPackagingType()!=null){
			changeTaskVo.setGoodsPackagingTypeS(goodsInfoDO.getGoodsPackagingType());//商品单位
		}else {
			changeTaskVo.setGoodsPackagingTypeS(" ");//商品单位
		}
		if (goodsInfoDO.getGoodsName()!=null) {
			
			changeTaskVo.setGoodsNameS(goodsInfoDO.getGoodsName());//商品名称
		}else{
			changeTaskVo.setGoodsNameS(" ");
			
		}
		if (goodsInfoDO.getGoodsStandard()!=null) {
			changeTaskVo.setGoodsStandardS(goodsInfoDO.getGoodsStandard());//商品规格
		} else {
			changeTaskVo.setGoodsStandardS(" ");//商品规格
		}
		if (tGoodsAllocationDO.getGoodsNumber()!=null) {
			changeTaskVo.setGoodsNumberS(tGoodsAllocationDO.getGoodsNumber());//仓位数量
		} else {
			
			changeTaskVo.setGoodsNumberS(0);//仓位数量
		}
		
		
		if (tGoodsAllocationDO2.getGoodsId()!=null) {
			if (changeTask.getAllocationNumberE()!=null) {
				changeTaskVo.setAllocationNumberE(changeTask.getAllocationNumberE());//目标仓位编号
			}else{
				changeTaskVo.setAllocationNumberE("");//目标仓位编号
			}
			if (goodsInfoDO.getGoodsPackagingType()!=null){
				changeTaskVo.setGoodsPackagingTypeE(goodsInfoDO.getGoodsPackagingType());//商品单位
			}else {
				changeTaskVo.setGoodsPackagingTypeE(" ");//商品单位
			}
			if (changeTask.getId()!=null) {
				changeTaskVo.setIdE(changeTask.getId());
			}else{
				changeTaskVo.setIdE(" ");
			}
			if (goodsInfoDO.getGoodsName()!=null) {
				changeTaskVo.setGoodsNameE(goodsInfoDO.getGoodsName());//商品名称
			} else {
				changeTaskVo.setGoodsNameE(" ");//商品名称
			}
			if (goodsInfoDO.getGoodsStandard()!=null) {
				changeTaskVo.setGoodsStandardE(goodsInfoDO.getGoodsStandard());//商品规格
			}else{
				changeTaskVo.setGoodsStandardE(" ");//商品规格
			}
			if (tGoodsAllocationDO2.getGoodsNumber()!=null) {
				changeTaskVo.setGoodsNumberE(tGoodsAllocationDO2.getGoodsNumber());//仓位数量
			} else {
				changeTaskVo.setGoodsNumberE(0);//仓位数量
			}
			
		}else {
			changeTaskVo.setAllocationNumberE(changeTask.getAllocationNumberE());//目标仓位编号
		}
	
		
	
		return changeTaskVo;
	}
	
	
	/**
	 * 叉车工调仓扫描初始仓位
	 * id 调仓任务ID
	 */
	@ResponseBody
	@GetMapping("/findMsg")
	public AppR findMsg(@RequestParam String id,@RequestParam String allocationNumber){
		ChangeTask changeTask = changeTaskService.get(id);
		if (changeTask!=null) {
			if (changeTask.getAllocationNumberS()!=null) {
				if (changeTask.getAllocationNumberS().equals(allocationNumber)) {
					//选定仓位里的详细商品信息，包括品名数量等
					//TGoodsAllocationDO tGoodsAllocationDO = goodsAllocationService.getOne(allocationNumber);
					//开始任务，修改状态
					ChangeTask changeTask2 = new ChangeTask();
					changeTask2.setTdStatus(2);
					changeTask2.setId(id);
					changeTaskService.update(changeTask2);
					//list(changeTask.getRoleId(),changeTask.getId());
                    Map<String,Object> map = new HashMap<>();
                    map.put("tdStatus",2);
					return AppR.ok(map);
					
				}else{
					return AppR.error(900,"不是待调仓仓位");
				}
			}else{
				return AppR.error(900,"初始仓位编号错误");
			}

		}else{
			return AppR.error(900,"信息错误");
		}

		
	}
	
	/**
	 * 叉车工扫描目标仓位，调仓完成
	 * roleId 登陆者ID
	 * id 调仓任务ID
	 */
	@ResponseBody
	@PostMapping("/finishMsg")
	public AppR finishMsg(@RequestParam Long roleId,@RequestParam String allocationNumberS,@RequestParam String allocationNumberE,String id){
		ChangeTask changeTask = changeTaskService.get(id);
		TGoodsAllocationDO list1 = goodsAllocationService.getOne(allocationNumberS);
		TGoodsAllocationDO list2 = goodsAllocationService.getOne(allocationNumberE);
		
		if (list1.getGoodsId() == null) {
			return AppR.error(900,"初始仓位不能是空或输入信息有误");
		}else if (list2.getGoodsId() ==null) {//目标仓位为空，解除锁定
		
			//将初始仓位中的商品ID 数量 时间保存在目标仓位
			goodsAllocationService.updateGoodids(list1.getGoodsId(),list1.getGoodsNumber(), new Date(),list2.getAllocationId());
			
			//清空初始仓位里商品信息
			goodsAllocationService.deleteOne(list1.getAllocationId());
			
			//解锁初始仓位和目标仓位
			goodsAllocationService.updateOne("120001",list1.getAllocationId());
			goodsAllocationService.updateOne("120003",list2.getAllocationId());
			
			//修改任务表状态,执行时间
			changeTaskService.updateOne( new Date(),roleId);
			
			//调仓完成后 更改任务状态为 12003 
			//ChangeTask changeTask = changeTaskService.get(id);
			if (changeTask.getTaskId() != null) {
				TTaskDO tTaskDO = new TTaskDO();
				tTaskDO.setTaskStatus("12003");
				tTaskDO.setTaskId(changeTask.getTaskId());
				tTaskService.update(tTaskDO);
				
				
				//完成调仓后 添加一条新的任务订单详情
				TTaskDatilDO datilDO = new TTaskDatilDO();
				datilDO.setTdGid(changeTask.getGoodsId());
				datilDO.setTdInitalAllocation(list2.getAllocationNumber());
				datilDO.setTdNumber(changeTask.getNeedNumber());
				datilDO.setTdStatus("12005");//状态未完成
				datilDO.setTdTaskId(Long.valueOf(changeTask.getTaskId()));
				
				Map<String, Object> map = new HashMap<>();
				map.put("tdGid", changeTask.getGoodsId());
				map.put("tdTaskId", changeTask.getTaskId()); 
				datilDO.setTdUnit(tTaskDatilService.list(map).get(0).getTdUnit()); //
				tTaskDatilService.save(datilDO);
				
			} 
		}else{

			if (!list1.getGoodsId().equals(list2.getGoodsId())) {
				return AppR.error(900,"非同一种商品不能合仓");
			}else{
				int num = 0;
				if (list2.getGoodsNumber()!=null) {
					num = list2.getGoodsNumber()+list1.getGoodsNumber();
				}else{
					num = list1.getGoodsNumber();
				}
				
				goodsAllocationService.updateGoodids(list1.getGoodsId(),num, new Date(),list2.getAllocationId());
				goodsAllocationService.deleteOne(list1.getAllocationId());
				goodsAllocationService.updateOne("120001",list1.getAllocationId());
				goodsAllocationService.updateOne("120003",list2.getAllocationId());
				changeTaskService.updateOne( new Date(),roleId);
				
				if (changeTask.getTaskId() != null ) {
					TTaskDO tTaskDO = new TTaskDO();
					tTaskDO.setTaskStatus("12003");
					tTaskDO.setTaskId(changeTask.getTaskId());
					tTaskService.update(tTaskDO);
					
					
					//完成调仓后 添加一条新的任务订单详情
					TTaskDatilDO datilDO = new TTaskDatilDO();
					datilDO.setTdGid(changeTask.getGoodsId());
					datilDO.setTdInitalAllocation(list2.getAllocationNumber());
					datilDO.setTdNumber(changeTask.getNeedNumber());
					datilDO.setTdStatus("12005");//状态未完成
					datilDO.setTdTaskId(Long.valueOf(changeTask.getTaskId()));
					
					Map<String, Object> map = new HashMap<>();
					map.put("tdGid", changeTask.getGoodsId());
					map.put("tdTaskId", changeTask.getTaskId()); 
					datilDO.setTdUnit(tTaskDatilService.list(map).get(0).getTdUnit()); //danwei
					tTaskDatilService.save(datilDO);
					
				}
			}

		}
		
		createTaskService.createTasks(changeTask.getProviderId());
		return AppR.ok("调仓完成");
	}

	/***
	 *特殊调仓时根据仓位号和商品条码查询商品信息
	 * @param allocationNumber 仓位编号
	 * @param goodsCode 商品条码
	 * @return
	 */
	@ResponseBody
	@PostMapping("/selectAloneMsg")
//	{"lists":[{"goodsId":6912084199768,"goodsNumber":21}],"context":"史蒂夫说","allocationNumberE":"B21116","allocationNumberS":"B21115","userId":1}
	public AppR alone(@RequestParam String allocationNumber,@RequestParam String goodsCode){

		TGoodsAllocationDO tGoodsAllocationDO = goodsAllocationService.getOne(allocationNumber);


		if (tGoodsAllocationDO != null) {
			if (tGoodsAllocationDO.getAllocationType().equals("122001") || tGoodsAllocationDO.getAllocationType().equals("122002")) {//初始仓位是正常仓位

				//根据商品条码查询商品ID
				Map<String,Object> map1 = new HashMap<>();
				map1.put("goodsCode", goodsCode);
				map1.put("providerId",tGoodsAllocationDO.getProviderId());

				GoodsInfoDO goodsInfoDO1 =goodsInfoService.getGoodsBySku(map1);

				Long goodsId = goodsInfoDO1.getGoodsId();
				if (tGoodsAllocationDO.getGoodsId() != goodsId) {
					return AppR.error(900,"商品条码不在仓位上");
				}else{
					GoodsInfoDO goodsInfoDO = goodsInfoService.get(goodsId);//商品信息
					if (goodsInfoDO!=null) {
						Map<String,Object> map = new HashMap<>();
						map.put("goodsName", goodsInfoDO.getGoodsName());//商品名称
						map.put("goodsStandard", goodsInfoDO.getGoodsStandard());//商品规格
						map.put("goodsNumber", tGoodsAllocationDO.getGoodsNumber());//商品数量
						map.put("goodsPackagingType",goodsInfoDO.getGoodsPackagingType());//商品单位
						return AppR.ok(map);
					}else{
						return AppR.error(900,"无详细商品信息");
					}

				}
			}else{//初始仓位是特殊仓位
				Map<String,Object> map1 = new HashMap<>();
				map1.put("goodsCode", goodsCode);
				map1.put("providerId",tGoodsAllocationDO.getProviderId());

				GoodsInfoDO goodsInfoDO1 =goodsInfoService.getGoodsBySku(map1);
				Long goodsId = goodsInfoDO1.getGoodsId();

				TGoodsAllocationAloneDO selectGoodsId = tGoodsAllocationAloneService.selectGoodsMsg(allocationNumber,goodsId);//特殊仓位查到商品信息
				if (selectGoodsId!=null) {
					Map<String,Object> map = new HashMap<>();
					map.put("goodsName", selectGoodsId.getGoodsName());//商品名称
					map.put("goodsStandard", selectGoodsId.getGoodsStandard());//商品规格
					map.put("goodsNumber", selectGoodsId.getGoodsNumber());//商品数量
					map.put("goodsPackagingType",selectGoodsId.getGoodsPackagingType());//商品单位
					return AppR.ok(map);
				}else{
					return AppR.error(900,"商品信息不存在");
				}

			}
		}else{
			return AppR.error(900,"仓位编号错误");
		}


	}
	/***
	 * 特殊调仓
	 * @param specialVo 特殊调仓参数信息
	 * @return
	 */

	@ResponseBody
	@PostMapping("/changeAloneMsg")
	public AppR alone(@RequestBody SpecialVo specialVo){

		if (specialVo!=null){
			if (specialVo.getAllocationNumberS()==null){
				return AppR.error(900,"初始仓位不能为空");
			}else {

				TGoodsAllocationDO tGoodsAllocationDO = goodsAllocationService.getOne(specialVo.getAllocationNumberS());
				TGoodsAllocationDO tGoodsAllocation = goodsAllocationService.getOne(specialVo.getAllocationNumberE());
				//判断初始仓位类型
				if (tGoodsAllocationDO.getAllocationType().equals("122001") || tGoodsAllocationDO.getAllocationType().equals("122002")){//初始仓位是正常仓位
					//判断目标仓位类型
					if (tGoodsAllocation.getAllocationType().equals("122001") || tGoodsAllocation.getAllocationType().equals("122002")){//目标仓位是正常仓位
						return AppR.error(900,"正常仓位间不能调仓");
					}else {//目标仓位是特殊仓位
						if (tGoodsAllocationDO.getGoodsId()!=null){
							//正常仓位到特殊仓位

							List<Map<String,Object>> list = specialVo.getLists();
							Object goodsId = list.get(0).get("goodsId");
							Integer goodsNumber = (Integer)list.get(0).get("goodsNumber");

							if (tGoodsAllocationDO.getGoodsNumber()>=goodsNumber){
								//带着商品ID查询特殊仓位信息
								TGoodsAllocationAloneDO selectGoodsId = tGoodsAllocationAloneService.selectGoodsMsg(specialVo.getAllocationNumberE(),tGoodsAllocationDO.getGoodsId());//特殊仓位查到商品信息


									if (selectGoodsId != null){//有到有
										//修改初始仓位数量
										TGoodsAllocationDO ta = new TGoodsAllocationDO();
										if (tGoodsAllocationDO.getGoodsNumber()!=null) {
											ta.setGoodsNumber(tGoodsAllocationDO.getGoodsNumber()-goodsNumber);
										}else{
											return AppR.ok("初始仓位数量异常");
										}

										ta.setAllocationId(tGoodsAllocationDO.getAllocationId());
										goodsAllocationService.update(ta);
										//修改目标仓位数量
										TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
										if (selectGoodsId.getGoodsNumber()!=null) {
											taa.setGoodsNumber(selectGoodsId.getGoodsNumber()+goodsNumber);
										}else{
											taa.setGoodsNumber(goodsNumber);
										}

										taa.setId(selectGoodsId.getId());
										tGoodsAllocationAloneService.update(taa);
										//添加记录
										saveNewMsg(specialVo.getAllocationNumberS(),specialVo.getAllocationNumberE(),specialVo.getContext(),specialVo.getUserId(),tGoodsAllocationDO.getGoodsId(),goodsNumber,tGoodsAllocationDO.getAllocationId(),tGoodsAllocation.getAllocationId(),tGoodsAllocationDO.getProviderId());

										TGoodsAllocationDO tGoodsAllocati = goodsAllocationService.getOne(specialVo.getAllocationNumberS());
										if (tGoodsAllocati.getGoodsNumber() == 0 || tGoodsAllocati.getGoodsNumber() == null){
											TGoodsAllocationDO tas = new TGoodsAllocationDO();
											tas.setPutTime(null);
											tas.setGoodsId(null);
											tas.setGoodsNumber(null);
											goodsAllocationService.save(tas);

										}

										//调仓完成
										return AppR.ok("调仓完成");
									}else {//有到无
										//修改初始仓位数量
										TGoodsAllocationDO ta = new TGoodsAllocationDO();
										if (tGoodsAllocationDO.getGoodsNumber()!=null) {
											ta.setGoodsNumber(tGoodsAllocationDO.getGoodsNumber()-goodsNumber);
										}else{
											return AppR.ok("初始仓位数量异常");
										}

										ta.setAllocationId(tGoodsAllocationDO.getAllocationId());
										goodsAllocationService.update(ta);
									//	修改目标仓位
										GoodsInfoDO goodsInfoDO = goodsInfoService.get(tGoodsAllocationDO.getGoodsId());
										TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
										String str = UUID.randomUUID().toString();
										taa.setId(str);
										taa.setAllocationNumber(specialVo.getAllocationNumberE());
										taa.setGoodsId(tGoodsAllocationDO.getGoodsId());
										taa.setCreateDate(new Date());
										//taa.setType();
										taa.setGoodsName(goodsInfoDO.getGoodsName());
										taa.setGoodsStandard(goodsInfoDO.getGoodsStandard());
										taa.setGoodsNumber(goodsNumber);
										taa.setgoodsPackagingType(goodsInfoDO.getGoodsPackagingType());
										tGoodsAllocationAloneService.save(taa);
										//添加记录
										saveNewMsg(specialVo.getAllocationNumberS(),specialVo.getAllocationNumberE(),specialVo.getContext(),specialVo.getUserId(),tGoodsAllocationDO.getGoodsId(),goodsNumber,tGoodsAllocationDO.getAllocationId(),tGoodsAllocation.getAllocationId(),tGoodsAllocationDO.getProviderId());

										TGoodsAllocationDO tGoodsAllocati = goodsAllocationService.getOne(specialVo.getAllocationNumberS());
										if (tGoodsAllocati.getGoodsNumber() == 0 || tGoodsAllocati.getGoodsNumber() == null){
											TGoodsAllocationDO tas = new TGoodsAllocationDO();
											tas.setPutTime(null);
											tas.setGoodsId(null);
											tas.setGoodsNumber(null);
											goodsAllocationService.save(tas);

										}
										return AppR.ok("调仓完成");
									}

							}else {
								return AppR.error(900,"数量不足");
							}


						}else {
							return AppR.error(900,"初始仓位无商品信息");
						}

					}
				}else {//初始仓位是特殊仓位
					//判断目标仓位类型
					if (tGoodsAllocation.getAllocationType().equals("122001") || tGoodsAllocation.getAllocationType().equals("122002")){//目标仓位是正常仓位
						//特殊仓位到正常仓位

					}else {//目标仓位是特殊仓位
						//特殊仓位到特殊仓位
						//查询特殊仓位信息
						List<Map<String,Object>> list = specialVo.getLists();
						Map<String,Object> lsss = list.get(0);
						Object ddd = lsss.get("goodsId");
						Object dddw = lsss.get("goodsNumber");
						int i = 0;

					}
				}
			}

		}else {
			return AppR.error(900,"调仓失败");
		}
		return null;
	}
	public void saveNewMsg(String AllocationNumberS,String AllocationNumberE,String context,Long userid,Long goodsId,Integer goodsNumber,Long allocationId,Long AllocationIdE,Long providerId){
		StaffUserDO staffUserDO = staffUserService.get(userid);
		ChangeTask ct = new ChangeTask();
		String str = UUID.randomUUID().toString();
		ct.setId(str);
		ct.setTdInitalAllocation(allocationId);//初始货位ID
		ct.setTdTargetAllocation(AllocationIdE);//目标id
		ct.setTdStime(new Date());//发起时间
		ct.setTdEtime(new Date());
		ct.setTdName(staffUserDO.getStaffName());
		ct.setTdDoname(staffUserDO.getStaffName());
		ct.setTdStatus(1);
		ct.setTdType(2);
		//ct.setRoleId(userid);
		ct.setProviderId(providerId);
		//ct.setOrderId();
		//ct.setQuickId();
		//ct.setTaskId();
		//ct.getNeedNumber();
		ct.setGoodsId(goodsId);
		ct.setAllocationNumberE(AllocationNumberE);
		ct.setAllocationNumberS(AllocationNumberS);
		ct.setContext(context);
		ct.setChangeNumber(goodsNumber);
		changeTaskService.save(ct);
		//return AppR.ok("调仓完成");

	}
//	{"lists":[{"goodsId":35,"goodsNumber":21},{"goodsId":35,"goodsNumber":21}],"context":"lih","allocationNumberE":"B21103","allocationNumberS":"B21101","userId":1}

//	/***
//	 * 执行特殊调仓
//	 * @param allocationNumberS 初始仓位编号
//	 * @param allocationNumberE 目标仓位编号
//	 * @param context 备注
//	 * @param goodsCode 商品条码
//	 * @param userid 登陆者ID
//	 * @param goodsNumberS 初始商品修改后的数量  可修改
//	 * @param goodsNumberS 目标商品修改后的数量  可修改
//	 * @return
//	 */
//	@ResponseBody
//	@PostMapping("/changeNumMsg")
//	public AppR changeNum(@RequestParam String allocationNumberS,@RequestParam String allocationNumberE,String context,@RequestParam Long userid,
//			@RequestParam String goodsCode,@RequestParam Integer goodsNumberS,@RequestParam Integer goodsNumberE){
//		
//		TGoodsAllocationDO tGoodsAllocationS = goodsAllocationService.getOne(allocationNumberS);
//		TGoodsAllocationDO tGoodsAllocationE = goodsAllocationService.getOne(allocationNumberE);
//		
//			if (tGoodsAllocationS.getAllocationType().equals("122001") || tGoodsAllocationS.getAllocationType().equals("122002")) {//初始仓位是正常仓位
//				if (tGoodsAllocationE.getAllocationType().equals("122001") || tGoodsAllocationE.getAllocationType().equals("122002")) {//目标仓位是正常仓位
//					return AppR.ok("正常仓位间不能调仓");
//				}else{
//					//正长仓位调仓到特殊仓位
//					if (goodsNumberS != goodsNumberE) {
//						return AppR.ok("调仓数量不一致");
//					}else{
//						if (tGoodsAllocationS.getGoodsNumber()<goodsNumberS) {
//							return AppR.ok("调仓数量应少于初始位原来数量");
//						}else{
//							if (tGoodsAllocationS.getGoodsId()!=goodsId) {
//								return AppR.ok("仓位与商品信息不一致");
//							}else{
//								TGoodsAllocationAloneDO selectGoodsId = tGoodsAllocationAloneService.selectGoodsMsg(allocationNumberE,goodsId);//目标仓位查到商品信息
//								if (selectGoodsId!=null) {//有到有
//									//修改正常仓位商品数量
//									changeRight(tGoodsAllocationS,goodsNumberS);
////									TGoodsAllocationDO ta = new TGoodsAllocationDO();
////									if (tGoodsAllocationS.getGoodsNumber()!=null) {
////										ta.setGoodsNumber(tGoodsAllocationS.getGoodsNumber()-goodsNumberS);
////									}else{
////										return AppR.ok("初始仓位数量异常");
////									}
////									
////									ta.setAllocationId(tGoodsAllocationS.getAllocationId());
////									goodsAllocationService.update(ta);
//									//修改特殊仓位商品数量
//									changeError(selectGoodsId,goodsNumberE);
////									TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
////									if (selectGoodsId.getGoodsNumber()!=null) {
////										taa.setGoodsNumber(selectGoodsId.getGoodsNumber()+goodsNumberE);
////									}else{
////										taa.setGoodsNumber(goodsNumberE);
////									}
////									
////									taa.setId(selectGoodsId.getId());
////									tGoodsAllocationAloneService.update(taa);
//									//添加记录
//									saveNewMsg(goodsNumberS,context,userid,tGoodsAllocationS,tGoodsAllocationE,goodsId,allocationNumberE,allocationNumberS);
//									return AppR.ok("调仓完成");
//								}else{//有到无
//									GoodsInfoDO goodsInfoDO = goodsInfoService.get(goodsId);
//									//修改正常仓位商品数量
//									changeRight(tGoodsAllocationS,goodsNumberS);
////									TGoodsAllocationDO ta = new TGoodsAllocationDO();
////									if (tGoodsAllocationS.getGoodsNumber()!=null) {
////										ta.setGoodsNumber(tGoodsAllocationS.getGoodsNumber()-goodsNumberS);
////									}else{
////										return AppR.ok("初始仓位数量异常");
////									}
////									
////									ta.setAllocationId(tGoodsAllocationS.getAllocationId());
////									goodsAllocationService.update(ta);
//									//修改特殊仓位商品数量
//									changeError(allocationNumberE,goodsId,goodsInfoDO,selectGoodsId,goodsNumberE);
////									TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();vbf
////									String str = UUID.randomUUID().toString();
////									taa.setId(str);
////									taa.setAllocationNumber(allocationNumberE);
////									taa.setGoodsId(goodsId);
////									taa.setCreateDate(new Date());
////									//taa.setType();
////									taa.setGoodsName(goodsInfoDO.getGoodsName());
////									taa.setGoodsStandard(goodsInfoDO.getGoodsStandard());
////									taa.setGoodsNumber(goodsNumberE);
////									tGoodsAllocationAloneService.save(taa);
//									//添加记录
//									saveNewMsg(goodsNumberS,context,userid,tGoodsAllocationS,tGoodsAllocationE,goodsId,allocationNumberE,allocationNumberS);
//									return AppR.ok("调仓完成");		
//								}
//							}
//							
//							
//						}
//					}	
//				}
//				
//			}else{//初始仓位是特殊仓位
//				Map<String,Object> map = new HashMap<>();
//		        map.put("goodsCode", goodsCode);
//		        map.put("providerId",tGoodsAllocationS.getProviderId());
//		        GoodsInfoDO goodsInfoDO1 =goodsInfoService.getGoodsBySku(map);
//		        Long goodsId = goodsInfoDO1.getGoodsId();
//				
//				
//				TGoodsAllocationAloneDO selectGoodsId = tGoodsAllocationAloneService.selectGoodsMsg(allocationNumberS,goodsId);//特殊初始仓位查到商品信息
//				TGoodsAllocationDO goodsAllocationE = goodsAllocationService.getOne(allocationNumberE);//判断目标仓位类型
//				if (goodsAllocationE == null) {
//					return AppR.ok("目标仓位号错误");
//				}else{
//					if (goodsAllocationE.getAllocationType().equals("122001") || goodsAllocationE.getAllocationType().equals("122002")) {//目标仓位是正常仓位
//						if (goodsNumberS != goodsNumberE) {
//							return AppR.ok("调仓数量不一致");
//						}else{
//							if (selectGoodsId.getGoodsNumber()<goodsNumberS) {
//								return AppR.ok("调仓数量应少于初始位原来数量");
//							}else{
//									if (goodsAllocationE.getGoodsId()==null ) {//有到无
//										//修改初始仓位商品数量
//										//changeRight(selectGoodsId,tGoodsAllocationS,goodsNumberS);
//											TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
//											if (selectGoodsId.getGoodsNumber()!=null) {
//												taa.setGoodsNumber(selectGoodsId.getGoodsNumber()-goodsNumberS);
//											}else{
//												return AppR.ok("初始仓位数量异常");
//											}
//											
//											taa.setId(selectGoodsId.getId());
//											tGoodsAllocationAloneService.update(taa);
//										//修改目标仓位商品数量
//										//www(goodsAllocationE,goodsNumberE,goodsId);
//											TGoodsAllocationDO ta = new TGoodsAllocationDO();
//											if (goodsAllocationE.getGoodsNumber()!=null) {
//												ta.setGoodsNumber(goodsAllocationE.getGoodsNumber()+goodsNumberE);
//											}else{
//												ta.setGoodsNumber(goodsNumberE);
//											}
//											ta.setGoodsId(goodsId);
//											ta.setAllocationId(goodsAllocationE.getAllocationId());
//											goodsAllocationService.update(ta);
//										
//										//添加记录
//										saveNewMsg(goodsNumberS,context,userid,tGoodsAllocationS,tGoodsAllocationE,goodsId,allocationNumberE,allocationNumberS);
//										return AppR.ok("调仓完成");
//									}else{//有到有
//										if (goodsAllocationE.getGoodsId()!=goodsId) {
//											return AppR.ok("商品在目标仓位不存在");
//										}else{
//											//修改初始仓位商品数量
//											//changeRight(selectGoodsId,tGoodsAllocationS,goodsNumberS);
//												TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
//												if (selectGoodsId.getGoodsNumber()!=null) {
//													taa.setGoodsNumber(selectGoodsId.getGoodsNumber()-goodsNumberS);
//												}else{
//													return AppR.ok("初始仓位数量异常");
//												}
//												
//												taa.setId(selectGoodsId.getId());
//												tGoodsAllocationAloneService.update(taa);
//											//修改目标仓位商品数量
//											//www(goodsAllocationE,goodsNumberE,goodsId);
//												TGoodsAllocationDO ta = new TGoodsAllocationDO();
//												if (goodsAllocationE.getGoodsNumber()!=null) {
//													ta.setGoodsNumber(goodsAllocationE.getGoodsNumber()+goodsNumberE);
//												}else{
//													ta.setGoodsNumber(goodsNumberE);
//												}
//												ta.setGoodsId(goodsId);
//												ta.setAllocationId(goodsAllocationE.getAllocationId());
//												goodsAllocationService.update(ta);
//											
//											//添加记录
//											saveNewMsg(goodsNumberS,context,userid,tGoodsAllocationS,tGoodsAllocationE,goodsId,allocationNumberE,allocationNumberS);
//											return AppR.ok("调仓完成");
//										}
//										
//									}					
//						     }
//					 }
//					}else{//目标仓位是特殊仓位
//						TGoodsAllocationAloneDO selectGoods = tGoodsAllocationAloneService.selectGoodsMsg(allocationNumberE,goodsId);//特殊目标仓位查到商品信息
//						if (selectGoods == null) {//有到无
//							rhr
//						}else{//有到有
//							if (goodsNumberS != goodsNumberE) {
//								return AppR.ok("调仓数量不一致");
//							}else{
//								if (selectGoodsId.getGoodsNumber()<goodsNumberS) {
//									return AppR.ok("调仓数量应少于初始位原来数量");
//								}else{
//										if (selectGoods.getGoodsId()==selectGoodsId.getGoodsId() ) {//有到无
//											//修改初始仓位商品数量
//											//changeRight(selectGoodsId,tGoodsAllocationS,goodsNumberS);
//												TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
//												if (selectGoodsId.getGoodsNumber()!=null) {
//													taa.setGoodsNumber(selectGoodsId.getGoodsNumber()-goodsNumberS);
//												}else{
//													return AppR.ok("初始仓位数量异常");
//												}
//												
//												taa.setId(selectGoodsId.getId());
//												tGoodsAllocationAloneService.update(taa);
//											//修改目标仓位商品数量
//											//www(goodsAllocationE,goodsNumberE,goodsId);
//												TGoodsAllocationDO ta = new TGoodsAllocationDO();
//												if (goodsAllocationE.getGoodsNumber()!=null) {
//													ta.setGoodsNumber(goodsAllocationE.getGoodsNumber()+goodsNumberE);
//												}else{
//													ta.setGoodsNumber(goodsNumberE);
//												}
//												ta.setGoodsId(goodsId);
//												ta.setAllocationId(goodsAllocationE.getAllocationId());
//												goodsAllocationService.update(ta);
//											
//											//添加记录
//											saveNewMsg(goodsNumberS,context,userid,tGoodsAllocationS,tGoodsAllocationE,goodsId,allocationNumberE,allocationNumberS);
//											return AppR.ok("调仓完成");
//										}else{//有到有
//											
//											
//										}					
//							     }
//						 }
//						}
//						
//						
//						
//						
//						
////						if (selectGoodsId.getGoodsId()!=goodsId ) {
////							return AppR.ok("仓位与商品信息不一致");
////						}else{
////						
////							
////							if (goodsNumberS != goodsNumberE) {
////								return AppR.ok("调仓数量不一致");
////							}else{
////								if (selectGoodsId.getGoodsNumber()<goodsNumberS) {
////									return AppR.ok("调仓数量应少于初始位原来数量");
////								}else{
////									TGoodsAllocationAloneDO selectGoodsid = tGoodsAllocationAloneService.selectGoodsMsg(allocationNumberE,goodsId);//目标仓位查到商品信息
////									if (selectGoodsid!=null) {//有到有
////										//修改初始仓位商品数量
////										//changeRight(selectGoodsId,tGoodsAllocationS,goodsNumberS);
////										TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
////										if (selectGoodsId.getGoodsNumber()!=null) {
////											taa.setGoodsNumber(selectGoodsId.getGoodsNumber()-goodsNumberS);
////										}else{
////											return AppR.ok("初始仓位数量异常");
////										}
////										
////										taa.setId(selectGoodsId.getId());
////										tGoodsAllocationAloneService.update(taa);
////										//修改目标仓位商品数量
////										TGoodsAllocationAloneDO ta = new TGoodsAllocationAloneDO();
////										if (selectGoodsid.getGoodsNumber()!=null) {
////											ta.setGoodsNumber(selectGoodsid.getGoodsNumber()+goodsNumberE);
////										}else{
////											ta.setGoodsNumber(goodsNumberE);
////										}
////										
////										ta.setId(selectGoodsid.getId());
////										tGoodsAllocationAloneService.update(ta);
////										
////										//添加记录
////										saveNewMsg(goodsNumberS,context,userid,tGoodsAllocationS,tGoodsAllocationE,goodsId,allocationNumberE,allocationNumberS);
////										return AppR.ok("调仓完成");
////									}else{//有到无
////										GoodsInfoDO goodsInfoDO = goodsInfoService.get(goodsId);
////										//修改初始仓位商品数量
////										TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
////										if (selectGoodsId.getGoodsNumber()!=null) {
////											taa.setGoodsNumber(selectGoodsId.getGoodsNumber()-goodsNumberS);
////										}else{
////											return AppR.ok("初始仓位数量异常");
////										}
////										
////										taa.setId(selectGoodsId.getId());
////										tGoodsAllocationAloneService.update(taa);
////										
////										//修改目标仓位商品数量
////										TGoodsAllocationAloneDO ta = new TGoodsAllocationAloneDO();
////										String str = UUID.randomUUID().toString();
////										ta.setId(str);
////										ta.setAllocationNumber(allocationNumberE);
////										ta.setGoodsId(goodsId);
////										ta.setCreateDate(new Date());
////										//taa.setType();
////										ta.setGoodsName(goodsInfoDO.getGoodsName());
////										ta.setGoodsStandard(goodsInfoDO.getGoodsStandard());
////										ta.setGoodsNumber(goodsNumberE);
////										tGoodsAllocationAloneService.save(ta);
////										//添加记录
////										saveNewMsg(goodsNumberS,context,userid,tGoodsAllocationS,tGoodsAllocationE,goodsId,allocationNumberE,allocationNumberS);
////										return AppR.ok("调仓完成");
////									}
////									
////								}
////							}
////						}
//						
//					}
//				}
//				
//			}
//		
//	}
//	

//	
//	/**
//	 * 有到有
//	 * 初始仓位是正常仓位
//	 * 修改初始仓位商品数量
//	 */
//	public AppR changeRight(TGoodsAllocationDO tGoodsAllocationS,Integer goodsNumberS){
//		TGoodsAllocationDO ta = new TGoodsAllocationDO();
//		if (tGoodsAllocationS.getGoodsNumber()!=null) {
//			ta.setGoodsNumber(tGoodsAllocationS.getGoodsNumber()-goodsNumberS);
//		}else{
//			return AppR.ok("初始仓位数量异常");
//		}
//		
//		ta.setAllocationId(tGoodsAllocationS.getAllocationId());
//		goodsAllocationService.update(ta);
//		return null;
//		
//		
//		
//		
//	}
//	/**
//	 * 有到有
//	 * 初始仓位是特殊仓位
//	 * 修改初始仓位商品数量
//	 */
//	public AppR changeRight(TGoodsAllocationAloneDO selectGoodsId,TGoodsAllocationDO tGoodsAllocationS,Integer goodsNumberS){
//		TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
//		if (selectGoodsId.getGoodsNumber()!=null) {
//			taa.setGoodsNumber(selectGoodsId.getGoodsNumber()-goodsNumberS);
//		}else{
//			return AppR.ok("初始仓位数量异常");
//		}
//		
//		taa.setId(selectGoodsId.getId());
//		tGoodsAllocationAloneService.update(taa);
//		return null;
//		
//		
//		
//	}
//	
//	/**
//	 * 有到有
//	 * 初始仓位是正常仓位
//	 * 修改特殊仓位商品数量
//	 */
//	public void changeError(TGoodsAllocationAloneDO selectGoodsId,Integer goodsNumberE){
//		TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
//		if (selectGoodsId.getGoodsNumber()!=null) {
//			taa.setGoodsNumber(selectGoodsId.getGoodsNumber()+goodsNumberE);
//		}else{
//			taa.setGoodsNumber(goodsNumberE);
//		}
//		
//		taa.setId(selectGoodsId.getId());
//		tGoodsAllocationAloneService.update(taa);
//		
//		
//		
//	}
//	/**
//	 * 有到wu
//	 * 初始仓位是正常仓位
//	 * 修改特殊仓位商品数量
//	 */
//	public void changeError(String allocationNumberE,Long goodsId,GoodsInfoDO goodsInfoDO,TGoodsAllocationAloneDO selectGoodsId,Integer goodsNumberE){
//		TGoodsAllocationAloneDO taa = new TGoodsAllocationAloneDO();
//		String str = UUID.randomUUID().toString();
//		taa.setId(str);
//		taa.setAllocationNumber(allocationNumberE);
//		taa.setGoodsId(goodsId);
//		taa.setCreateDate(new Date());
//		//taa.setType();
//		taa.setGoodsName(goodsInfoDO.getGoodsName());
//		taa.setGoodsStandard(goodsInfoDO.getGoodsStandard());
//		taa.setGoodsNumber(goodsNumberE);
//		tGoodsAllocationAloneService.save(taa);
//		
//		
//		
//	}
//	
//	public void www(TGoodsAllocationDO goodsAllocationE,Integer goodsNumberE,Long goodsId){
//		TGoodsAllocationDO ta = new TGoodsAllocationDO();
//		if (goodsAllocationE.getGoodsNumber()!=null) {
//			ta.setGoodsNumber(goodsAllocationE.getGoodsNumber()+goodsNumberE);
//		}else{
//			ta.setGoodsNumber(goodsNumberE);
//		}
//		ta.setGoodsId(goodsId);
//		ta.setAllocationId(goodsAllocationE.getAllocationId());
//		goodsAllocationService.update(ta);
//		
//		
//		
//	}
}







